import request from '@/libs/request';
var _self;
export const index =  {
	name: 'deliverListPopup',
	props: {
		show:{type:Boolean,default:false},
		dataInfo:{type:Object,default:{}},
		optData:{type:Object,default:{}}
	},
	watch:{
		popupShow(val){
			this.$emit('update:show', val);
			this.popupOpt();
		},
		
		show(val) {
			this.initData();
			this.popupShow = val;
			this.popupOpt();
		},

		selectList(val){
			this.$emit('update:dataInfo', this.selectItem);
		},
		
		dataInfo(val) {
			this.selectItem = val;
		}
	},
	data() {
		return {
			params:{
				page: 1,
				pageSize: 20,
			},
	
			selectItem:{},
			selectList:[],
			dataList:[],
			popupShow:this.show,
			scrollHeight:uni.getSystemInfoSync().windowHeight*0.6+"px",
			icons:[
				{type:"search",size:uni.upx2px(30)},
				{type:"camera",size:uni.upx2px(30)},
				{type:"search",size:uni.upx2px(40)},
				{type:"checkmarkempty",size:uni.upx2px(60)},
			],
			dateNow: new Date().Format("yyyy-MM-dd"),
		}
	},
	created() {
		_self=this;
	},
	
	methods:{
		
		initData: async function(){
			let retData=await request({url: '/api/Order/cerpDelivers',method: 'POST',data:{"order_id":this.optData.order_id}});
			this.dataList=retData.dataList;
			for(let index in this.selectItem) this.selectList.push(this.selectItem[index]["code"]);
			
		},
		
		change:function(e) {
			this.popupShow=e.show;
		},
		
		popupOpt:function(show){
			if(this.popupShow){
				this.$refs.popup.open('bottom');
			}else{
				this.$refs.popup.close();
			}
		},
		searchInfo:function(show){
			this.initData();
		},
		selectInfo:function(index){
			let itemKey=this.dataList[index]["cCode"];
			if(this.selectItem[itemKey]){
				let key=this.selectList.indexOf(this.selectItem[itemKey]["cCode"]);
				this.selectList.splice(key, 1); 
				delete this.selectItem[itemKey];
			}else{
				this.selectItem[itemKey]=this.dataList[index];
				this.selectList.push(this.dataList[index]["cCode"]);
			}
			
		
		},
		
		confirmSelect:function(){
			this.$refs.popup.close();
		}
		

	}
		

}